package leetcode.每日一题;

import leetcode.剑指offer.pojo.TreeNode;
import org.junit.Test;

import java.util.*;

/**
 * @author ：zsy
 * @date ：Created 2021/11/26 15:39
 * @description：https://leetcode-cn.com/problems/search-in-a-binary-search-tree/
 */
public class 二叉搜索树中的搜索 {
    @Test
    public void test() {
        Solution solution = new Solution();
    }

    class Solution {
        public TreeNode searchBST(TreeNode root, int val) {
            while (root != null) {
                if (root.val == val) return root;
                root = root.val > val ? root.left : root.right;
            }
            return null;
        }
    }

}
